package com.jsz.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jsz.constant.MessageConstant;
import com.jsz.entity.Result;
import com.jsz.pojo.Setmeal;
import com.jsz.service.SetmealService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 移动端--查询套餐信息设置
 */
@RestController
@RequestMapping("/setmeal")
public class SetmealController {
    @Reference
    private SetmealService setmealService;

    //查询所有套餐信息
    @RequestMapping("/mobile_findALLSetmeal")
    public Result mobile_findALLSetmeal() {
        try {
            List<Setmeal> list = setmealService.mobile_findALLSetmeal();

            //调试
           // System.out.println("list = " + list);
            //查询晨晨成功
            return new Result(true, MessageConstant.GET_SETMEAL_LIST_SUCCESS, list);
        } catch (Exception e) {
            return new Result(false, MessageConstant.GET_SETMEAL_LIST_FAIL);
        }
    }

    //根据套餐ID查询套餐详情(包含套餐信息,套餐关联的检查组信息,检查组关联的检查项信息)
    @RequestMapping("/mobile_findById")
    public Result mobile_findById(Integer id) {
        try {
            //调用业务层操作数据
            Setmeal setmeal = setmealService.mobile_findById(id);
            //调试
            System.out.println("setmeal = " + setmeal);
            return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS, setmeal);
        } catch (Exception e) {
            //查询失败
            return new Result(false, MessageConstant.QUERY_SETMEAL_FAIL);
        }
    }
}
